
'''
M: 一错都错
'''
def Initialise():
    global Jobs, NumberOfJobs
    for i in range(0,99):
        Jobs[0][i] = -1
        Jobs[1][i] = -1  # -2
    NumberOfJobs = 0


def AddJob(JobNumber,Priority):
    global Jobs, NumberOfJobs
    if NumberOfJobs == 100:
        return 'Not Added'  # M： 是output 读读题 -1
    else:
        # M： 为啥要单独考虑0呢
        if NumberOfJobs == 0:
            Jobs[0][0] = JobNumber
            Jobs[1][0] = Priority
        else:
            Jobs[0][NumberOfJobs] = JobNumber
            Jobs[1][NumberOfJobs] = Priority  # M： 还是赋值不对 -1
        NumberOfJobs+=1
        return 'Added'  # M： 是output 读读题 -1

'''
函数名字不一致是会扣分的 -1
while 比较 -1
最后的插入 -1
'''
def InsertSort():
    global Jobs, NumberOfJobs
    for i in range(1,NumberOfJobs):
        key = Jobs[1][i]
        j = i-1
        while j <= i and key < Jobs[1][j]:
            Jobs[0][j],Jobs[0][j+1] = Jobs[0][j+1],Jobs[0][j]
            Jobs[1][j],Jobs[1][j+1] = Jobs[1][j+1],Jobs[1][j]
            j -=1
        Jobs[1][j+1] = key

# M： -1 -1
def PrintArray():
    for x in range(0,99):
        print(f'{Jobs[0][x]} priority {Jobs[1][x]}')


if __name__ == '__main__':
    global Jobs, NumberOfJobs
    Jobs = [[0 for i in range(100)],[0 for j in range(100)]]  # M: 2D array 行列有问题 -1
    NumberOfJobs= 100  # 这句话暂时可以不要

    Initialise()
    AddJob(12,10)
    AddJob(526,9)
    AddJob(33,8)
    AddJob(12,9)
    AddJob(78,1)

    InsertSort()
    PrintArray()
